﻿CREATE TABLE [dbo].[tblCall]
(
	CallID int identity(1,1) NOT NULL primary key, 
	CallStartTime smalldatetime not null,
	Duration int not null, -- Call duration in seconds
	NumberID int null,
	CallerID varchar(15) null,
	LocationID int null,
	CallTypeCode char(1) not null,
	UserID int null,
	CustomerID int null,
	NoteID int null,
	OwnerID int null,
	PBXId varchar(20) null
)
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Defines a telephone call, incomming or outgoing.', @level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'primary key.  Uniquely identifies the call.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'CallID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Reters to the tblNumber table.  For inbound calls identifies the number dialed.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'NumberID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Identifies the number the customer is calling from for inbound calls.  Identifies the number dialed for outbound calls.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'CallerID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Refers to the tblLocation table.  Identifies the call center location.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'LocationID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Refers to the codeCallType table.  Identifies the call type (inbound/outbound).', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'CallTypeCode';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Refers to the tblUser table.  Identifies the agent on the call.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'UserID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Refers to the tblNote table.  Identifies the notes taken during the call.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'NoteID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'This value comes from the PBX to uniquely identify the call within the PBX.  This allows for reporting to link this call record with PBX information.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblCall',
	@level2type = N'COLUMN', @level2name = N'PBXId';
GO;
